<template>
  <el-row class="container">
    <!-- 头部 -->
    <el-col class="header" :span="24">
      <el-col class="logo" :span="10" :class="logoTitle?'logo-small-width':'logo-normal-width'">
        {{logoTitle?'':systemName}}
      </el-col>
      <el-col :span="10">
        <div>
          <i class="nav-arrow" :class="logoTitle?'el-icon-d-arrow-right':'el-icon-d-arrow-left'" @click.prevent="logoSizeToggle"></i>
        </div>
      </el-col>
      <el-col class="user-info" :span="4">
        <el-dropdown trigger="click">
          <span class="el-dropdown-link">
            {{systemUser}} <img class="user-head-img" :src="imageUrl" alt=""><i class="el-icon-arrow-down el-icon--right"></i>
          </span>
          <!-- <span>111</span><img src="" alt=""><i class="el-icon-arrow-down el-icon--right"></i> -->
          <el-dropdown-menu slot="dropdown" style="width:150px;">
            <el-dropdown-item>我的信息</el-dropdown-item>
            <el-dropdown-item>设置</el-dropdown-item>
            <el-dropdown-item divided @click.native.prevent="dialogVisible = true">退出</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </el-col>
    </el-col>

    <!-- 页面中部 -->
    <el-col class="main" :span="24">
      <aside style="width:240px;background:white;" :class="logoTitle?'menu-small-width':'menu-normal-width'">
        <!-- 测试用例 -->
        <el-menu default-active="/table" unique-opened router>
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>导航一</span>
            </template>
            <el-menu-item index="/table">table 表格</el-menu-item>
            <el-menu-item index="/form">form 表单</el-menu-item>
            <el-menu-item index="/list">list 列表</el-menu-item>
          </el-submenu>
          <el-menu-item index="2">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span>导航二</span>
            </template>
          </el-menu-item>
          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-share"></i>
              <span>导航三</span>
            </template>
            <el-menu-item index="3-1">选项1</el-menu-item>
            <el-menu-item index="3-2">选项2</el-menu-item>
          </el-submenu>
        </el-menu>
      </aside>

      <section class="content_view">
        <el-col :span="24" class="breadcrumb_title"> 
          <el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: '/test' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>活动管理</el-breadcrumb-item>
            <el-breadcrumb-item>活动管理</el-breadcrumb-item>
          </el-breadcrumb>
        </el-col> 
        <hr>
        <el-col :span="24"> 
          <transition name="el-fade-in-linear" mode="out-in">
            <router-view></router-view>
          </transition>
        </el-col>  
      </section>
    </el-col>

    <!-- 弹出框 -->
    <el-dialog
      title="提示"
      width="400px"
      :visible.sync="dialogVisible"
      >
      <span>确定要退出系统吗？</span>
      <span slot="footer">
        <el-button @click.native.prevent="dialogVisible = false">取消</el-button>
        <el-button class="submitBtn" @click.native.prevent="loginOut">确定</el-button>
      </span>
    </el-dialog>

  </el-row>
</template>
<script>
export default {
  name: 'home',
  data () {
    return {
      logoTitle: false,
      systemName: 'XXSystem',
      systemUser: '测试用户',
      imageUrl: '../../static/images/headTest.png',
      dialogVisible: false
    }
  },
  methods: {
    logoSizeToggle () {
      this.logoTitle = !this.logoTitle
    },
    loginOut () {
      // window.localStorage.removeItem('user')
      // window.localStorage.removeItem('pwd')
      this.$router.push({path: '/login'})
    }
  }
}
</script>
<style lang="stylus" scoped>
@import '~@/styles/theme.styl'
.container
  width 100%
  height 100%
  .header
    height 60px
    line-height 60px
    background bgColor
    .logo
      padding-left 20px
      height 60px
      font-size 22px
      color white
      border-color rgba(238,241,146,0.3)
      border-right-width 1px
      border-right-style solid
      // cursor pointer
      transition .2s
    .logo-normal-width
      width 240px
    .logo-small-width
      width 60px
    .nav-arrow
      margin-left 10px
      font-size 24px
      line-height 60px
      color white
      cursor pointer
    .user-info
      float right
      padding-right 20px
      text-align right
      .el-dropdown-link
        display inline-block
        color white
        cursor pointer
        .user-head-img
          margin 0 5px
          width 40px
          height 40px
          border-radius 50%
          vertical-align middle
  .submitBtn
    background bgColor
    color white
    &:hover
      background #5ca2d6
  .main
    display flex
    position absolute
    top 60px
    bottom 0px
    overflow hidden
    .content_view
      padding 10px
      flex-grow 1
      background #eee
      .breadcrumb_title
        padding-bottom 10px

</style>


